package com.java.thread.consumer;

public class Sample {

	private int num;

	public synchronized void increase(){
		while (num != 0){
			try {
				this.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		num ++;
		System.out.println(num);
		this.notify();
	}

	public synchronized void decrease(){
		while (num != 1){
			try {
				this.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		num --;
		System.out.println(num);
		this.notify();
	}

}
